<?php

namespace app\api\logic;

use app\common\model\Area;

class AreaLogic
{
    protected Area $model;

    public function __construct()
    {
        $this->model = new Area();
    }

    public function selectList(array $param)
    {
        $query = $this->model
            ->field('id,shortname,name,level');
        if ($param['keyword']) {
            $query->whereLike('name|shortname','%'.$param['keyword'].'%');
        }
        if ($param['level']) {
            $query->where('level',$param['level']);
        }

        return $query->order('id ASC')
            ->select();
    }

}